package game;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

public class AbstractMovingSprite extends AbstractSprite implements
		MovingSprite {
	
	protected Direction verticalDirection = Direction.NONE;
	
	protected Direction horizontalDirection = Direction.NONE;
	
	protected float speed = 0.2f;
	
	public AbstractMovingSprite(int x, int y, int width, int height, Color color) {
		super(x, y, width, height, color);
	}
	
	@Override
	public float getSpeed() {
		return speed;
	}
	
	@Override
	public Direction getVerticalDirection() {
		return verticalDirection;
	}
	
	@Override
	public Direction getHorizontalDirection() {
		return horizontalDirection;
	}
	
	public void setVerticalDirection(Direction verticalDirection) {
		this.verticalDirection = verticalDirection;
	}
	
	public void setHorizontalDirection(Direction horizontalDirection) {
		this.horizontalDirection = horizontalDirection;
	}
	
	private List<CollisionListener> collisionListeners = new ArrayList<CollisionListener>();
	
	public void addCollisionListener(CollisionListener collisionListener) {
		collisionListeners.add(collisionListener);
	}
	
	@Override
	public void triggerCollision(ArrayList<Collision> collisions) {
		for (CollisionListener collisionListener : collisionListeners) {
			collisionListener.collision(collisions);
		}
	}

}
